<include file="__PUBLIC__/header"/>
<div class="page-container">
    <!--菜单-->
    <div class="cl pd-5 bg-1 bk-gray mt-10 mb-10">
        <form action="{|U:'backup_db'}" method="post">
            <table class="table table-border table-bordered table-bg mt-10 table-sort" width="100%">
                <tr>
                    <td>分卷大小(KB)</td>
                    <td>
                        <input type="text" class="input-text" name="size" value="200"/>
                    </td>
                    <td>
                        <input type="submit" class="btn btn-primary-outline" value="开始备份"/>
                    </td>
                </tr>

            </table>
        </form>
    </div>
    <!--列表-->
    <table class="table table-border table-bordered table-bg mt-10 table-sort" id="table">
        <thead>
        <tr class="text-c">
            <th>
                <label><input type="checkbox" class="s_all_ck" value="" checked=""></label>
            </th>
            <th>表名</th>
            <th>类型</th>
            <th>编码</th>
            <th>记录数</th>
            <th>使用空间</th>
            <th>碎片</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <list from="$table.table" name="$t">
            <tr class="text-c">
                <td>
                    <input type="checkbox" name="table[]" value="{$t.tablename}" checked=""/>
                </td>
                <td>{$t.tablename}</td>
                <td>{$t.engine}</td>
                <td>{$t.charset}</td>
                <td>{$t.rows}</td>
                <td>{$t.size}</td>
                <td>{$t.data_free|default:0}</td>
                <td>
                    <a href="javascript:;" onclick="ajax_req('{|U:'optimize'}',{table:['{$t.tablename}']})" class="label label-secondary radius">优化</a>
                    <a href="javascript:;" onclick="ajax_req('{|U:'repair'}',{table:['{$t.tablename}']})" class="label label-warning radius">修复</a>
                </td>
            </tr>
        </list>
    </table>
    <br/>
    <div class="btn btn-primary" onclick="optimize()" >批量优化</div>
    <div class="btn btn-primary" onclick="repair()">批量修复</div>
</div>
<include file="__PUBLIC__/footer"/>
<script>
    //全选与反选
    $(".s_all_ck").click(function () {
        $("[name='table[]']").attr("checked", !!$(this).attr("checked"));
    })

    //检查有没有选择备份目录
    function check_select_table() {
        if ($("[name*='table']:checked").length == 0) {
            layer.alert("你还没有选择表");
            return false;
        }
        return true;
    }

    //优化表
    function optimize() {
        if (check_select_table()) {
            ajax_req('{|U:'optimize'}',$("[name*='table']:checked").serialize());
        }
    }
    //修复表
    function repair() {
        if (check_select_table()) {
            ajax_req('{|U:'repair'}',$("[name*='table']:checked").serialize());
        }
    }
</script>
</body>
</html>